package com.njxxted.activiti.modules.process.extend.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.njxxted.activiti.common.util.PageUtil;
import com.njxxted.activiti.common.util.UserUtil;
import com.njxxted.activiti.modules.api.entity.UserDto;
import com.njxxted.activiti.modules.process.extend.dao.ExtendActCopyDao;
import com.njxxted.activiti.modules.process.extend.entity.ExtendActCopyEntity;
import com.njxxted.activiti.modules.process.extend.service.ExtendActCopyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * 描述：流程抄送表 service
 * <p>
 * 作者：HuTongFu
 * 邮箱：hu_tongfu@163.com
 * 时间：2019-08-19 10:07:17
 */
@Service("extendActCopyService")
public class ExtendActCopyServiceImpl implements ExtendActCopyService {

    @Resource
    private ExtendActCopyDao extendActCopyDao;

    @Override
    public ExtendActCopyEntity queryObject(String id) {
        return extendActCopyDao.queryObject(id);
    }

    @Override
    public PageUtil<ExtendActCopyEntity> queryList(ExtendActCopyEntity param) {
        if (Objects.isNull(param)) {
            return null;
        }
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<ExtendActCopyEntity> extendActCopyEntityList = extendActCopyDao.queryList(param);
        PageInfo<ExtendActCopyEntity> pageInfo = new PageInfo<>(extendActCopyEntityList);
        return new PageUtil<>(extendActCopyEntityList, (int) pageInfo.getTotal(), pageInfo.getPageSize(), pageInfo.getPageNum());

    }

    @Override
    public List<ExtendActCopyEntity> queryListByBean(ExtendActCopyEntity param) {
        return extendActCopyDao.queryListByBean(param);
    }

    @Override
    public int save(ExtendActCopyEntity extendActCopyEntity) {
        return extendActCopyDao.save(extendActCopyEntity);
    }

    @Override
    public int update(ExtendActCopyEntity extendActCopyEntity) {
        UserDto userFromRedis = UserUtil.getUserFromRedis();
        extendActCopyEntity.setUserId(userFromRedis.getId());
        return extendActCopyDao.update(extendActCopyEntity);
    }

    @Override
    public int delete(String id) {
        return extendActCopyDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return extendActCopyDao.deleteBatch(ids);
    }

}
